/**
 * 
 */
package com.seascape.swms.system.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.google.common.collect.ImmutableMap;
import com.seascape.swms.framework.service.BaseService;
import com.seascape.swms.system.model.Resource;
import com.seascape.swms.system.shiro.ShiroUtils;

/**
 * @author Lay
 *
 */
@Service
public class ResourceService extends BaseService<Resource>{

	public List<Resource> queryResourcesByRoleId(Integer roleId){
		Map<String,Object> params = ImmutableMap.<String,Object>builder().put("roleId",roleId).build();
		return sqlManager.select("roleResource.queryResourcesByRoleId", Resource.class, params);
	}
	
	public List<Resource> queryResourcesByCurrentUser(){
		String userCode = ShiroUtils.getPrincipal();
		Map<String,Object> params = ImmutableMap.<String,Object>builder().put("userCode",userCode).put("kind","M").build();
		return sqlManager.select("userResource.qeuryResourcesByUserCode", Resource.class,params);
	}
}
